<template>
    <div class="newinfo-container">
        <!--上方区域-->
        <h3 class="title">{{newsInfo.title}}</h3>
        <p class="subtitle">
            <span>发表时间：{{newsInfo.add_time | dataFormat}}</span>
            <span>点击：{{newsInfo.click}}次</span>
        </p>
        <hr>
        <!--内容区域-->
        <div class="content">{{newsInfo.content}}</div>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <!--评论区域-->
        <commentBox :id="this.id"></commentBox>

    </div>
</template>

<script>
    import { Toast } from 'mint-ui';
    import comment from '../comment/comment.vue'
export default {
    data(){
        return {
            id:this.$route.params.id,
            newsInfo:{},
        }
    },
    created(){
       this.getNewsInfo()
    },
    methods:{
        getNewsInfo(){
            this.$http.get('http://127.0.0.1:3001/getnewinfo?id='+this.id).then((result)=>{
                if(result.body.code === '0'){
                    this.newsInfo = result.body.newsinfo;
                    console.log(result.body.newsinfo);
                }else{
                    Toast('网络抽风了');
                }
            }).catch(function (err) {
                console.log(err);
            })
        }
    },
    components:{
        'commentBox':comment
    }
}
</script>

<style scoped lang="less">
    .newinfo-container{
        padding: 0 8px;
        .title{
            font-size: 16px;
            text-align: center;
            margin: 15px 0;
        }
        .subtitle{
            font-size: 13px;
            color: #226aff;
            display: flex;
            justify-content: space-between;
        }
    }
</style>